package gameLevel.classicLevel;

import gameBasics.GameModel;
import object.CommandPost;
import object.Wall;
import tank.EnemyTank;
import tank.MainTank;
import java.util.ArrayList;

public abstract class ClassicLevel {

    protected final ArrayList<EnemyTank> enemyTanks = new ArrayList<>();

    public ClassicLevel() {
        MainTank mainTank = GameModel.getInstance().getMainTank();
        mainTank.setLivingState(true);
        initClassicLevel(mainTank);
    }

    protected void initClassicLevel(MainTank mainTank) {
        //添加主坦克
        GameModel.getInstance().addGameObject(mainTank);

        //初始化敌对坦克
        initEnemyTanks();

        //初始化指挥所布局
        initCommandPostLayout();

        //初始化其它地形布局
        initTerrainLayout();
    }

    /**
     * 初始化敌对坦克
     */
    protected abstract void initEnemyTanks();

    /**
     * 初始化指挥所布局
     */
    protected void initCommandPostLayout(){
        new Wall(355, 530);
        new Wall(385, 530);
        new Wall(355, 560);
        new CommandPost(385, 560);
        new Wall(415, 530);
        new Wall(415, 560);
    }

    /**
     * 初始化其它地形布局(除指挥所外)
     */
    protected abstract void initTerrainLayout();

    /**
     * 设置敌对坦克移动
     */
    protected void enemyTankMove(){
        for(EnemyTank enemyTank : enemyTanks){
            enemyTank.setMovingState(true);
        }
    }

}
